package ai.people.netmon.telegram.controller;

import ai.people.netmon.framework.domain.telegram.vo.attribution.Attribution;
import ai.people.netmon.framework.domain.telegram.vo.attribution.PhoneAttribution;
import ai.people.netmon.framework.model.response.PageResponse;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.netmon.telegram.domain.request.attribution.AttributionRequest;
import ai.people.netmon.telegram.service.AttributionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 属地线索
 *
 * @author yuanqinglong
 * @date 2022/1/17 13:58
 */
@Validated
@RestController
@RequestMapping("/attribution")
public class AttributionController {


    @Autowired
    private AttributionService attributionServiceImpl;


    /**
     * 电话归属
     *
     * @param attributionRequest 页面关键字请求
     * @return {@link Result}<{@link PageResponse}<{@link PhoneAttribution}>>
     */
    @PostMapping("/phoneAttribution")
    public Result<PageResponse<PhoneAttribution>> phoneAttribution(@Valid @RequestBody AttributionRequest attributionRequest) {
        PageResponse<PhoneAttribution> phoneAttributionList = attributionServiceImpl.phoneAttributionList(attributionRequest);
        return ResultUtil.success(phoneAttributionList);
    }


    /**
     * 地址定位
     *
     * @param attributionRequest 页面关键字请求
     * @return {@link Result}<{@link PageResponse}<{@link Attribution}>>
     */
    @PostMapping("/addressTargeting")
    public Result<PageResponse<Attribution>> addressTargeting(@Valid @RequestBody AttributionRequest attributionRequest) {
        PageResponse<Attribution> addressTargetingList = attributionServiceImpl.addressTargetingList(attributionRequest);
        return ResultUtil.success(addressTargetingList);
    }


}
